/**
 * Created by WLG on 2018/11/15.
 */
let moment = require('moment');
let colors = require('colors');
let uuid = require('uuid');
moment.locale('zh-cn');

/*colors.setTheme({
    silly: 'rainbow',
    input: 'grey',
    verbose: 'cyan',
    prompt: 'grey',
    info: 'green',
    data: 'grey',
    help: 'cyan',
    warn: 'yellow',
    debug: 'blue',
    error: 'red'
});*/

class CommonUtil{
    static arrayRemoveOne(array,one){
        let result = [];
        for (let i = 0; i < array.length; i++) {
            let temp = array[i];
            if (temp === one) {
            }else{
                result.push(temp);
            }
        }
        return result;
    }
    static createUUID(){
        return uuid.v1().replace(/\-/g,'');
    }
    static consoleSysInfo(){
        let arr = Array.prototype.slice.call(arguments);
        this.consoleUtil(arr.join('-'),'green');
    }
    static consoleTestInfo(){
        let arr = Array.prototype.slice.call(arguments);
        this.consoleUtil(arr.join('-'),'cyan');
    }
    static consoleRed(){
        let arr = Array.prototype.slice.call(arguments);
        this.consoleUtil(arr.join('-'),'red');
    }
    static consoleBlue(){
        let arr = Array.prototype.slice.call(arguments);
        this.consoleUtil(arr.join('-'),'blue');
    }
    static consoleUtil(msg,color){
        console.log((this.formatDate(new Date().getTime())+" - "+msg)[color]);
    }
    static formatDate(time){
        return moment(time).format('YYYY-MM-DD HH:mm:ss'); /*格式化时间*/
    }
}
module["exports"] = CommonUtil;